//
//  FindPasswordView.m
//  HappyBaby
//
//  Created by lanou on 15/11/30.
//  Copyright © 2015年 华哥. All rights reserved.
//

#import "FindPasswordView.h"
#import "Define.h"
@implementation FindPasswordView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        CGFloat width = 260 * kScaleX;
        CGFloat x = (kScreenWidth - width)/2;
        CGFloat height = 30 * kScaleY;
        CGFloat ySpace = height + 40*kScaleY;
        NSArray *titleArray = @[@"请输入新密码",@"请再次输入密码"];
        // 循环创建textFiled
        
        self.password = [[UITextField alloc] initWithFrame:CGRectMake(x, 50*kScaleY + ySpace, width, height)];
        self.password.borderStyle = UITextBorderStyleBezel;
        self.password.backgroundColor = [UIColor colorWithRed:226/255.0 green:226/255.0 blue:226/255.0 alpha:1];
        self.password.placeholder = titleArray[0];
        self.password.delegate = self;
        self.password.secureTextEntry = YES;
        UIView *smallView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10*kScaleX, height)];
        _password.leftView = smallView;
        _password.leftViewMode = UITextFieldViewModeAlways;
        [self addSubview:_password];
       
        
        self.passwordAgian = [[UITextField alloc] initWithFrame:CGRectMake(x, 50*kScaleY + ySpace*2, width, height)];
        self.passwordAgian.borderStyle = UITextBorderStyleBezel;
        self.passwordAgian.backgroundColor = [UIColor colorWithRed:226/255.0 green:226/255.0 blue:226/255.0 alpha:1];
        self.passwordAgian.placeholder = titleArray[1];
        self.passwordAgian.delegate = self;
        self.passwordAgian.secureTextEntry = YES;
        UIView *smallView2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10*kScaleX, height)];
        _passwordAgian.leftView = smallView2;
        _passwordAgian.leftViewMode = UITextFieldViewModeAlways;
        [self addSubview:_passwordAgian];
        
        
       
        self.resetBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.resetBtn.frame = CGRectMake(x, self.passwordAgian.y + ySpace, width, height) ;
        [self.resetBtn setTitle:@"重置密码" forState:UIControlStateNormal];
        self.resetBtn.backgroundColor = [UIColor colorWithRed:88/255.0 green:137/255.0 blue:236/255.0 alpha:1];
        [self addSubview:_resetBtn];
        
        
    }
    return self;
}

// 点击return回收键盘
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
    return YES;
}
// 触摸空白回收键盘
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.password resignFirstResponder];
    [self.passwordAgian resignFirstResponder];
}



@end
